package org.hfy.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 付款方式枚举
 * 
 * @author hfy
 * @version 1.0
 */
@Getter
@AllArgsConstructor
public enum PaymentMethodEnum {
    
    CASH("CASH", "现金"),
    MONTHLY_30("MONTHLY_30", "月结30天"),
    MONTHLY_60("MONTHLY_60", "月结60天");
    
    private final String code;
    private final String description;
    
    /**
     * 根据代码获取枚举
     */
    public static PaymentMethodEnum fromCode(String code) {
        for (PaymentMethodEnum method : PaymentMethodEnum.values()) {
            if (method.getCode().equals(code)) {
                return method;
            }
        }
        throw new IllegalArgumentException("未知的付款方式代码: " + code);
    }
    
    /**
     * 根据描述获取枚举
     */
    public static PaymentMethodEnum fromDescription(String description) {
        for (PaymentMethodEnum method : PaymentMethodEnum.values()) {
            if (method.getDescription().equals(description)) {
                return method;
            }
        }
        throw new IllegalArgumentException("未知的付款方式描述: " + description);
    }
} 